
import request from './request'
// import request from './index'

/**
 * 
 * @param {点赞} params 
 *  "accountId": "int //所属对象【必须】",
    "type": "int //点赞类型【必须】 0：点赞帖子，1：点赞评论，2：点赞回复",===========================================
    "targetId": "int //点赞对象【必须】，帖子或ping"
}
 */
export function thumbsUp(params) {
    let { accountId, type, targetId } = params
    let data = { accountId, type, targetId }
    console.log(data)
    return request({
        url: '/community/thumbsUp',
        method: 'Post',
        data
    })
}
/**============================================================================================================= */
/**
 * 
 * @param {新增回复} params 
 * 
 *  "content": "string //回复内容【必须】",
    "replyTo": "int //回复对象id，replyType为1传评论的id，replyType=2传回复的id",
    "replyType": "int //回复类型，1：回复评论，2：回复回复",
    "accountId": "int //评论所属对象",
    "evaluateId": "所属评论id"
}
 */
export function reply(params) {
    let { content, replyTo, replyType, accountId, evaluateId } = params
    let data = { content, replyTo, replyType, accountId, evaluateId }
    return request({
        url: '/community/reply',
        method: 'POST',
        data
    })
}
/**============================================================================================================= */
/**
 * 
 * @param {查询所有标签} params 
 */
export function label(params) {
    return request({
        url: '/community/label',
        method: 'get',
    })
}
/**============================================================================================================= */

/**
 * 
 * @param {获取用户信息_论坛用} params 
 */
export function accountInfo(params) {
    return request({
        url: '/community/account/info?accountId=' + params.id,
        method: 'get',
    })
}
/**
 * 
 * @param {删除贴子} params 
 */
export function deletePost(params) {
    let { id } = params
    let data = { id }
    return request({
        url: '/community/post',
        method: 'delete',
        data
    })

}

/**
 * 
 * @param {分页查询帖子} params 
 */
export function postsList(params) {
    console.log(params)
    let { pageNum, pageSize, accountId, labelId, title } = params
    let data = { pageNum, pageSize, accountId, labelId, title }
    console.log(data)
    return request({
        url: '/community/post/posts',
        method: 'get',
        params: data
    })
}
/**
 * 
 * @param {查询贴子详情} params 
 */
export function getPost(params) {
    let { id } = params
    let data = { id }
    console.log(data)
    return request({
        url: '/community/post',
        method: 'get',
        params: data
    })
}
/**
 * 
 * @param {发布贴子} params 
 */
export function addPost(params) {
    let { content, accountId, title, labelId, topping } = params
    let data = { content, accountId, title, labelId, topping }
    console.log(data)
    return request({
        url: '/community/post',
        method: 'Post',
        data
    })
}



